<script>
	import routeInterceptor from '@/util/router/index.ts'
	import roleStore from '@/store/role-play.js'
	import store from '@/store/index.js'
	export default {
		onLaunch: async function(e) {
			if (e.path.includes('pages_network')) {
				roleStore.commit('set_rolePlay', 'u-network')
			} else {
				roleStore.commit('set_rolePlay', 'u-user')
			}
			var pages = getCurrentPages();
			var page = pages[pages.length - 1];
			let token = uni.getStorageSync('dd-access-network').token
			if (token && roleStore.state.rolePlay == 'u-network') {
				uni.reLaunch({
					url: '/pages/pages_network/home/home'
				})
			}
			let tokenUser = uni.getStorageSync('dd-access-user').token
			if (tokenUser && roleStore.state.rolePlay == 'u-user') {
				uni.reLaunch({
					url: '/pages/home/home'
				})
			}
			if (roleStore.state.rolePlay == 'u-user') {
				if (e.query.custCode) {
					uni.setStorageSync('custCode', e.query.custCode)
				}
				if (e.query.moduleCode) {
					store.commit('setWayType', {
						id: e.query.moduleCode,
						name: '报单',
						type: e.query.type,
						factoryId: e.factoryCode || ''
					})
				}
				uni.removeStorageSync('dd-access-network')
			} else {
				if (!roleStore.state.rolePlay) {
					roleStore.commit('set_rolePlay', 'network')
				}
				uni.removeStorageSync('dd-access-user')
			}
			// 对路由进行统一拦截，实现路由导航守卫 router.beforeEach 功能
		},
		onShow: function() {
			// wx.hideTabBar({})//去掉自带的tabar
			routeInterceptor() // 调用路由拦截函数
		},
		onHide: function() {
			uni.hideLoading()
		},
		onLoad: function(e) {
			// e
		}
	}
</script>

<style lang="scss">
	/*每个页面公共css */
	:deep(.uni-modal__title) {
		font-size: 32rpx !important;
	}

	:deep(.uni-modal__bd) {
		color: #000 !important;
	}

	:deep(.uni-modal__ft) {
		// font-size: 32rpx !important;
	}

	#app {
		background-color: #fafafa;
		font-size: 32rpx;
		-webkit-user-select: text;
		-moz-user-select: text;
		-ms-user-select: text;
		user-select: text;

		:deep(.uni-page-head .uni-page-head__title) {
			font-size: 32rpx !important;
			font-weight: normal;
		}

		:deep(.uni-tabbar__label) {
			margin-top: 0 !important;
		}
	}
</style>